package com.itheima.网络编程.tcp编程.tcp编程.文件上传线程池三;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.UUID;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class 服务端 {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(13333);
        ThreadPoolExecutor tp = new ThreadPoolExecutor(
                3,
                10,
                60,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(10),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
        while (true) {
            Socket sk = ss.accept();
//            ThreadTcp tt=new ThreadTcp(sk);
//            new Thread(tt).start();
//            ThreadTcp tt = new ThreadTcp(sk);
////            tp.submit(tt);
            tp.submit(new ThreadTcp(sk));
        }
        //ss.close();
    }
}
